<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.ld.com/shield/tags" prefix="shield"%>
<%@ taglib uri="http://www.ld.com/system/tags" prefix="system"%>
<%@ page trimDirectiveWhitespaces="true" %>
<fmt:setLocale value="zh_CN"/>
<%-- 权限判断 --%>
<shield:permssion type="button">
<!-- shieldZtreeBtnContainer,ztree的按钮容器 -->
<div id="searchResult" class="shieldZtreeBtnContainer show-info" style="height: 400px;">
	<div class="ztree-box clearfix">
			<div class="ztree-search mt20">
				<form action="${ctxPathA}/system/role/savePermission" method="post" t="searchResult" class="form-search" id="sysmenuSearchForm">
					<shield:token/>
					<input type="hidden" name="id" value="${id }">
					<input type="hidden" id="permissiondata" name="permissiondata" value="${permissionData}"/>
					<input type="hidden" id="changeCount" value=""/>
					<div class="search clearfix mb10" style="margin-left: 32px;" >
						名称：<input type="text" name="like_name" id="keyword" value="${name }" style="width:150px;">
						<!-- shieldZTreeSearch,对树进行筛选 -->
						<input class="button submit shieldZTreeSearch" type="button" value="查询">
					</div>
					<div id="searchResult"></div>
					<div class="search-bt mb15 taCenter">
						<input type="button" class="expandAll button default" value="全部展开"/>
						<input type="button" class="collapseAll button default" value="全部收起"/>
						<!-- shieldZTreeRefresh,刷新树 -->
       					<input type="button" class="shieldZTreeRefresh button" value="刷新"/>
       					
					</div>	
				
			<!-- shieldZTree,selectNode表示默认选中第一个节点selectNode表示默认选中的节点（key=value形式或直接写value，直接写value默认可以为rownum），
			clickExtendFn="newsItemClickExtendFn" 为自定义的节点点击扩展方法
			shieldSettings用于设置一些插件支持的参数,data-url-add定义新增按钮的url【非必需，没有可不填】
     			data-upd-url定义修改按钮的url【非必需，没有可不填】selectNodem
     			data-del-url定义删除按钮的url【非必需，没有可不填】 paramAdapter进行点击时的参数适配treeNode为源
     			paramAdapter代表返回的参数多个参数用#号分隔，本例中id>typeId#newsType 代表取node中id的属性作为参数名为typeId的参数，newsType参数名不变，
			即最终拼出的url为system/menu/search?typeId=${node的id属性}&newsType=${newsType的id属性} 
				也可以直接在node中增加urlNode属性： map.put("urlNode", "/specialTopic/toSearch");
     			-->
             <ul style="padding-left:45px;" class="ztree shieldZTree" id="menuTree" data-url="${ctxPathA}/system/role/permissiondata?id=${id }" shieldSettings="{callback: {onCheck: onCheck},check:{enable: true, chkboxType:{ 'Y' : 'p', 'N' : 'ps' }}}" paramAdapter="id" selectNode="0" >
             </ul>
             <div class="search-bt mb20 taCenter">
       					<input type="button" class="allSelect default" value="全选"/>
						<input type="button" class="unSelect default" value="反选"/>
						<input type="button" class="unAllSelect default" value="全不选"/>
					</div>	
					<div class="search-bt taCenter">
						<input  type="submit" class="submit" value="保存修改"/>
					</div>	
             </form>

		</div>
		<div id="roleResults" >	
			<!-- ztreeContent为点击之后的容器 -->
     		<div class="ztreeContent"></div>
		</div>
		<div>
	        <ul id="log" class="log"></ul>
		</div>
	</div>
	<script type="text/javascript">
	<%-- 选中节点  --%>
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj(treeId),
		checkNodes = zTree.getCheckedNodes(true),
		changeCount = zTree.getChangeCheckedNodes().length;
		$("#permissiondata").val("");
		for(var i=0;i<checkNodes.length;i++){
			if($("#permissiondata").val()){
				$("#permissiondata").val($("#permissiondata").val()+","+checkNodes[i].id);					
			}else{
				$("#permissiondata").val(checkNodes[i].id);
			}
			
		}
		$("#changeCount").text(changeCount);
	}
	</script>
</div>
</shield:permssion>
